package com.example.common;

import lombok.Data;

@Data
public class Result {
    public static final String SUCCESS = "0";
    public static final String ERROR = "-1";
    private String code;
    private String msg;
    private Object data;

    public Result(){

    }

    public Result(String msg){
        this.msg = msg;
    }

    public static Result success(){
        Result result = new Result();
        result.setCode(SUCCESS);
        return result;
    }

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result error(String msg){
        Result result = new Result(msg);
        result.setCode(ERROR);
        result.setData(msg);
        return result;
    }
}
